$MVC.Controller('main',{
	'#register_button click' : function(params){
		document.getElementById('register').style.display = 'block';
		document.getElementById('register_button').className = 'selected';
		document.getElementById('login').style.display = 'none';
		document.getElementById('login_button').className = '';
		params.element.blur();
	},
	'#login_button click' : function(params){
		document.getElementById('register').style.display = 'none';
		document.getElementById('register_button').className = '';
		document.getElementById('login').style.display = 'block';
		document.getElementById('login_button').className = 'selected';
		params.event.kill();
		params.element.blur();
	},
	'form input focus' : function(params){
		params.element.style.color = 'black';
		if(params.element.type == 'submit') return;
		var value = params.element.value;
		if(value == params.element.getAttribute('default')){
			params.element.value = '';
			params.element.style.color = 'black';
			if(params.element.id.match('password')){
				if($MVC.Browser.IE || $MVC.Browser.WebKit){  //you can change webkit, but can't focus
					var newel = changeInputType(params.element, 'password');
					newel.style.fontSize = '14pt';
					setTimeout(function(){
						newel.focus();
					},10);
				}else{
					params.element.type = 'password';
					params.element.value = '';
					params.element.focus();
				}
				
				
			}
		}
	},
	'form input blur' : function(params){
		if(params.element.type == 'submit') return;
		var value = params.element.value;
		if(value == ''){
			params.element.value = params.element.getAttribute('default');
			params.element.style.color = 'Gray';
			if($MVC.Browser.IE){
				changeInputType(params.element, 'text');
			}else{
				params.element.type = 'text';
			}
		}
		
	}
});

changeInputType = function(oldObject, oType){
  var newObject = document.createElement('input');
  newObject.type = oType;
  if(oldObject.size) newObject.size = oldObject.size;
  if(oldObject.value) newObject.value = oldObject.value;
  if(oldObject.name) newObject.name = oldObject.name;
  if(oldObject.id) newObject.id = oldObject.id;
  if(oldObject.className) newObject.className = oldObject.className;
  newObject.setAttribute('default', oldObject.getAttribute('default'));
  oldObject.parentNode.replaceChild(newObject,oldObject);
  return newObject;
};